//
//  DropDownListViewController.m
//  maintain
//
//  Created by wmzheng on 15-1-20.
//  Copyright (c) 2015年 ewin. All rights reserved.
//

#import "DropDownListViewController.h"
#import "UIView+Extension.h"

@interface DropDownListViewController () {
    NSArray* contentArray;
}

@end

@implementation DropDownListViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.title = @"选择故障原因";
    self.view.height = 0;
    contentArray = @[ @"环境", @"自然损耗", @"人为", @"产品质量", @"施工",@"遗留问题", @"其他" ];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
}
#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView*)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section
{
    return [contentArray count];
}

- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{

    static NSString* CellIdentifier = @"DropDownListViewControllerCellIdentifier";
    UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    cell.accessoryType = UITableViewCellAccessoryNone;
    if (self.currentIndex==indexPath.row) {
        cell.accessoryType = UITableViewCellAccessoryCheckmark;
    }
    cell.textLabel.text = [contentArray objectAtIndex:indexPath.row];
    return cell;
}
#pragma mark Table view delegate

- (CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath
{
    return 40;
}
- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
{
//    _currentIndex = indexPath.row;
//    [tableView reloadData];
    NSString* content = [contentArray objectAtIndex:indexPath.row];
    if ([_delegate respondsToSelector:@selector(selectValue:andContent:)]) {
        [_delegate selectValue:indexPath.row andContent:content];
    }
    [self.navigationController popViewControllerAnimated:YES];
}
@end
